package book.ioperations;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperations implements IOperations{
    public void work(BookList bookList){
        System.out.println("借阅图书...");

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要查找的图书名：");
        String name = scanner.nextLine();

        int currentsize = bookList.getUsedSize();

        for (int i = 0; i < currentsize; i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)){
                System.out.println("已找到...\n书籍信息为：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("未找到此书...");
    }
}
